import React, { Component } from 'react';
import './style.less';
import { inject, observer } from 'mobx-react';
import { Button } from 'antd';

@inject('appStore')
@observer
class Login extends Component {
  state = {
    userName: '',
    password: ''
  };

  loginFn = () => {
    const res = {
      code: 0,
      data: {
        token: 'abcdefghijklmopqrstuvwxyz',
        userinfo: {
          id: '007',
          name: 'Warren Lee',
          address: '湖南长沙',
          phone: '18088888888'
        }
      }
    }
    this.props.appStore.setToken(res.data.token)
    this.props.appStore.setLoginUser(res.data.userinfo)
    this.props.history.push('/home');
  }

  render() {
    return (
      <div className="page-wrap login-wrap">
        <Button type="primary" onClick={this.loginFn}>Login</Button>
      </div>
    )
  }
}

export default Login;